//
//  LGProductDetailHeader.m
//  LuxuryGoods
//
//  Created by 刘星辰 on 2018/5/28.
//  Copyright © 2018年 Future. All rights reserved.
//

#import "LGProductDetailHeader.h"

@interface LGProductDetailHeader()<SDCycleScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@end

@implementation LGProductDetailHeader

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if ([super initWithCoder:aDecoder])
    {
        self.banner = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH)delegate:self placeholderImage:nil];
        self.banner.showPageControl = NO;
        [self.contentView addSubview:self.banner];
        
        UILabel * countLab =  [[UILabel alloc] init];
        countLab.font = FONT(10);
        countLab.textColor = WHITE_COLOR;
        countLab.textAlignment = NSTextAlignmentCenter;
        countLab.numberOfLines = 0;
        countLab.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
        self.countLab = countLab;
        [self.countLab setCornerRadius:11.f];
        [self.contentView addSubview:countLab];
        [self.countLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(40, 22));
            make.right.equalTo(self.banner.mas_right).offset(-15);
            make.bottom.equalTo(self.banner.mas_bottom).offset(-15);
        }];
    }
    return self;
}

- (void)awakeFromNib
{
    [super awakeFromNib];
  
    self.countLab.text = [NSString stringWithFormat:@"1/%lu",self.banner.localizationImageNamesGroup.count];
    
    [self.bottomView removeFromSuperview];
    [self.contentView addSubview:self.bottomView];
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(110);
    }];
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.contentView bringSubviewToFront:self.countLab];

//     [self.contentView bringSubviewToFront:self.bottomView];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

/** 图片滚动回调 */
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index
{
    self.countLab.text = [NSString stringWithFormat:@"%lu/%lu",index + 1,cycleScrollView.localizationImageNamesGroup.count];
}

- (IBAction)buttonClick:(id)sender {
    
}

@end
